#pragma once

#include <stdint.h>
#include "Part.h"
#include "Common/SceneDefine.h"

enum
{
	PVP_TIMER_UPDATE = 1,
	PVP_TIMER_KILL_VALUE = 2,
};

class PvpPart : public Part
{
public:
	PvpPart();
	virtual ~PvpPart();
public:
	//生物init调用
	virtual bool Init(Creature *pMaster, uint32_t partType, CharacterDBInfo* pCharacterDB = nullptr);
	//生物uint调用
	virtual bool UnInit();
public:
	//事件和时间调用的直接用下面的就行了
	virtual void OnExecute(uint16_t nEventID, uint64_t nSrcID, uint8_t bySrcType, void *pContext, int32_t nLen);
	virtual void OnTimer(uint32_t nTimerId);
	//客户端消息入口
	virtual bool OnMsgHandle(uint32_t cmd, const char* data, uint32_t len);
	//生物update
	virtual void Update(uint64_t tick) { }

	virtual void OnTimerHandleUpdate();
	//生物存储DB部件入口
	virtual bool SaveDB(CharacterDBInfo& characterDB);
	//生物登入同步客户度数据入口
	virtual bool SynOnLogin(PlayerClientInfo& playerInfo);

	virtual void BeforeChangeLogic();
	//杀戮值惩罚
	bool  PKValuePunish();
	//获取杀戮惩罚的坐标和地图
	bool GetPKValuePunishInfo(uint32_t &mapid,uint32_t & sceneId, Point3<float> & pos);
	void CountKillValueTimer();
public:
	void	MsgHandleSwitchPkMode(const char* data, uint32_t len);
	void	SendPvpKillingValue();
public:
	void	 AddPkKillingValue(uint32_t addon);
	void	 SubPkKillingValue(uint32_t addon);
	uint32_t GetPkKillingValue() const;
	uint32_t GetPkMode() const;
	void     SetPkMode(uint32_t pkMode);
	void	 AddRedPlayer(Player* player);
	void	 ClearAllRedPlayer();
	void	 SubRedPlayer(CharIDType player);
	bool	 IsRedPlayer(Player* player);
	bool	 IsWanted() const; //是否被通缉
	void	 CountPkKillingValue(CharIDType killerCid, CharIDType beKillerCid);
	void	 CountBeAttack(CharIDType attackCid);
	
	const PkmodePkWantedCfgInfo*  GetPkKillingValueConfig();
private:
	uint32_t			m_pkMode;
	uint32_t			m_pkKillingValue;
	uint64_t			m_lastSubPkValueTime;
	uint64_t			m_onlineTime;
	bool				m_pkValueTimerFlag;
	std::map<CharIDType, uint64_t> m_redStatus; //被攻击红名状态, key 是玩家的cid, value是红名倒计时到时时间
	std::vector<uint32_t> m_vPKReadLineLimit;	//通辑等级上限(严格按照 C级 B级 A级 S级 SSS级 的顺序)，根据这个值来区分该玩家所属的PK等级
};
